import { PureComponent } from "react";
import { Button, Modal,ActivityIndicator,InputItem,NavBar,Icon,TabBar } from "antd-mobile"
import { connect } from 'dva';
import { handleImg, goToPage,isNull } from "../../utils/helper";
import { setLogout } from "../../utils/request"
import { Row, Col,Select } from 'antd';
import {IntlProvider, addLocaleData,FormattedMessage} from 'react-intl';
import localeData from '../../../public/lang/data.json';
import 'antd/dist/antd.css'; // or 'antd/dist/antd.less'
import MToast from '../../components/Util/MToast';
@connect(() => {
  return ({

  })
})

export default class CustomerType extends PureComponent{
  constructor(props){
    super(props);
    this.state = {

    }
  }
  componentWillMount(){
    let {dispatch,location} = this.props;
    dispatch({
      type: "global/setHeaderTitle",
      payload: {
        title: T(localeData[localStorage.locale].customerType),
        path: location.pathname + location.search
      }
    });
    console.log(typeof(localStorage[MI_APP_CODE + "phone"]));
    // undefined
    if(localStorage[MI_APP_CODE + "phone"]!==undefined){
      console.log("1")
      this.setState({
        noLogin:true
      })
      if(localStorage[MI_APP_CODE + "bindName"]!==""){
        this.setState({
          bindCus:false,
        })

      }else{
        this.setState({
          bindCus:false,
        })
      }

    }else{
      console.log("2")
      this.setState({
        noLogin:false
      })

    }

    // 调用商品的列表是为了获取store_id
//     dispatch({
//       type: "form/query",
//       payload: {
//         apiInfo: {
//           url: "qry/all?_c=app_goods_list",
//           params: [
//           ],
//           _c: "app_goods_list"
//         },
//         callback: (result) => {
//           let { data } = result;
//           console.log(data);
// console.log(data[0].store_id)
//           localStorage.setItem("store_id",data[0].store_id)
//
//         }
//       }
//     });
  }

  retailClick=()=>{
    let { dispatch, location } = this.props;
    goToPage({ dispatch, config: { url: "/retail?type=T1" }, })
  }
  invoiceClick=()=>{
    let { dispatch, location } = this.props;
    goToPage({ dispatch, config: { url: "/retail?type=T0" }, })
  }
  render(){
    let {dispatch} = this.props;
    let {img,img1,noLogin,bindCus} = this.state;
    const messages = localeData[localStorage.locale];
    return(
      <IntlProvider
        locale={ localStorage.locale } messages={messages}
      >
      <div style={{height:"100%",background:'#fff'}}>
        <div style={{padding:'15% 38px 0px'}}>
       <p style={{color:'#303133',fontSize:"17px"}}>{messages.customerType}</p>
          <div style={{width:'200px',margin:"33px auto"}}>
            <Button style={{width: '200px',
              height: '42px',
              background: '#FF9F00',
              borderRadius: '20px',color:'#fff',fontSize:'13px',lineHeight:'42px'}} onClick={this.retailClick}>{messages.greenCodeTitle7}</Button>
            <Button style={{width: '200px',
              height: '42px',
              background: '#FF9F00',
              marginTop:'32px',
              borderRadius: '20px',color:'#fff',fontSize:'13px',lineHeight:'42px'}} onClick={this.invoiceClick}>{messages.greenCodeTitle8}</Button>
          </div>

        </div>
      </div>
      </IntlProvider>
    )
  }
}
